<!--
 * @Description: 
 * @Date: 2024-06-12 08:52:40
 * @LastEditTime: 2024-06-24 10:45:18
-->
<route lang="json5" type="login">
{
  style: {
    navigationStyle: 'custom',
    navigationBarTitleText: '身份认证',
  },
}
</route>
<template>
  <view
    class="w-screen h-screen p-t-300rpx px-40rpx flex flex-col box-border overflow-hidden bg-#fff"
  >
    <view class="text-40rpx font-550">身份认证</view>
    <view class="mt-30rpx mb-10rpx">为确保能够提供更精准有效的服务，需获取</view>
    <view>您的身份信息进行身份验证，请填写真实信息！</view>
    <view class="mt-60rpx mb-100rpx">
      <view class="mb-20rpx border-rd-20rpx overflow-hidden">
        <wd-input
          v-model="userInfo.name"
          placeholder="请输入真实姓名"
          size="large"
          no-border="true"
          prefix-icon="user"
        />
      </view>
      <view class="mb-20rpx border-rd-20rpx overflow-hidden">
        <wd-input
          v-model="userInfo.idCard"
          type="idcard"
          size="large"
          no-border="true"
          placeholder="请输入身份证号码"
          prefix-icon="note"
          class="w-100%"
        />
      </view>
    </view>
    <view class="w-100%">
      <wd-button :round="false" type="primary" size="large" block @click="submitFace">
        提交信息
      </wd-button>
    </view>
  </view>
</template>
<script setup>
import { updateNameAPI } from '@/service/index/foo'
import { useUserStore } from '@/store'
const userStore = useUserStore()
const userInfo = reactive({
  name: '',
  idCard: '',
})
onShow(() => {
  console.log('初始化')
})
function submitFace() {
  wx.startFacialRecognitionVerify({
    name: userInfo.name,
    idCardNumber: userInfo.idCard,
    success(e) {
      userStore.setUserInfo({
        nickname: userInfo.name,
      })
      updateNameAPI({ userId: userStore.userInfo.userId }, { ...toRaw(userInfo) }).then((res) => {
        uni.switchTab({ url: '/pages/home/index' })
      })
    },
    fail(error) {
      userInfo.name = ''
      userInfo.idCard = ''
      console.log(error, 11111111)
    },
  })
}
</script>
<style lang="scss" scope>
::v-deep .wd-input {
  background: #f8f8f8 !important;
}
::v-deep .wd-input__clear {
  background: #f8f8f8 !important;
}
</style>
